package main

import "fmt"

func main() {
	//test1()
	//test2()
	test3()
}

func test1() {
	darr := [...]int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	a := darr[2:5]
	fmt.Println(a)
	for i := range a {
		a[i]++
	}
	fmt.Printf("darr = %v\n", darr)
	fmt.Printf("a = %v\n", a)
}

//将切片的 第一位更改 数组对应位置的数据也将更改
func test2() {
	darr := [...]int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	a := darr[2:5]
	fmt.Println(a)
	a[0] = a[0] + 10
	fmt.Printf("darr = %v\n", darr)
	fmt.Printf("a = %v\n", a)
}

func test3() {
	numa := [...]int{78, 79, 80}
	nums1 := numa[:]
	nums2 := numa[:]
	fmt.Printf("numa = %v\n", numa) //[78 79 80]
	nums1[0] = 100
	fmt.Printf("numa = %v\n", numa) //[100 79 80]
	nums2[1] = 101
	fmt.Printf("numa = %v\n", numa) // [100 101 80]
}
